<!DOCTYPE html>

<html lang="zh-Hans">
  <head>
    <meta charset="utf-8" />
    <meta name="author" content="rogepi" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="/vue.global.js"></script>
    <title>3-event-handling</title>
  </head>

  <body>
    <!-- 为了让用户和应用进行交互，我们可以用 v-on 指令添加一个事件监听器，
    通过它调用在实例中定义的方法：：-->
    <div id="event-handling">
      <p>{{message}}</p>
      <button v-on:click="reverseMessage">反转</button>
    </div>

    <script>
      const EventHandling = {
        data() {
          return {
            message: 'Hello Vue.js!',
          };
        },
        methods: {
          reverseMessage() {
            this.message = this.message.split('').reverse().join('');
          },
        },
      };
      Vue.createApp(EventHandling).mount('#event-handling');
    </script>
  </body>
</html>
